package com.chenfan.mcn.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.chenfan.common.vo.Response;
import com.chenfan.mcn.model.dto.KocProjectSearchDto;
import com.chenfan.mcn.model.dto.KocpmHeaderDto;
import com.chenfan.mcn.model.vo.KocProjectSearchVO;
import com.chenfan.mcn.model.vo.KocpmHeaderVo;
import com.chenfan.mcn.service.DocKocpmHeaderService;
import com.chenfan.privilege.common.config.SearchAuthority;
import com.chenfan.privilege.common.config.UrlAuth;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * KOC项目管理
 *
 * @author liuming
 * @since 2022-05-12
 */
@Deprecated
//@RestController
@RequestMapping("/kocpmHeader")
public class KocpmHeaderController {

    @Autowired
    private DocKocpmHeaderService docKocpmHeaderService;

    /**
     * 分页查询
     * @param po
     * @param pageNum
     * @param pageSize
     * @return
     */
    @GetMapping(value = "getPage")
    @UrlAuth({"KOCProject_search"})
    public Response<Page<KocpmHeaderDto>> page(@SearchAuthority KocpmHeaderVo po,
                                               @RequestParam(name = "pageNum") Integer pageNum,
                                               @RequestParam(name = "pageSize") Integer pageSize) {
        return docKocpmHeaderService.getPage(po, pageNum, pageSize);
    }

    /**
     * 详情
     * @param kocpmId
     * @return
     */
    @GetMapping(value = "/info", produces = {"application/json;charset=UTF-8"})
    public Response<KocpmHeaderDto> info(@RequestParam("kocpmId") Long kocpmId) {
        KocProjectSearchDto dto = new KocProjectSearchDto();
        dto.setKocpmId(kocpmId);
        return docKocpmHeaderService.getInfo(dto);
    }

    /**
     * 获取列表
     * @param po
     * @return
     */
    @GetMapping(value = "/getList", produces = {"application/json;charset=UTF-8"})
    public Response<List<KocpmHeaderDto>> getList(KocpmHeaderVo po) {
        return docKocpmHeaderService.getList(po);
    }

    /**
     * 新增/编辑
     * @param vo
     * @return
     */
    @PostMapping(value = "/addOrEdit")
    public Response addOrEdit(@Validated @RequestBody KocpmHeaderVo vo) {
        return docKocpmHeaderService.addOrUpdate(vo);
    }


    /**
     * 详情
     * @param dto
     * @return
     */
    @PostMapping(value = "/getInfo", produces = {"application/json;charset=UTF-8"})
    public Response<KocpmHeaderDto> getInfo(@RequestBody KocProjectSearchDto dto) {
        return docKocpmHeaderService.getInfo(dto);
    }

    /**
     * 启用/禁用
     * @param vo
     * @return
     */
    @PostMapping(value = "/enable")
    @UrlAuth({"KOCProject_status"})
    public Response enable(@RequestBody KocpmHeaderVo vo) {
        return docKocpmHeaderService.enable(vo);
    }

    /**
     * kou红人选择
     *
     * @param kocProjectSearchDto
     * @return
     */
    @PostMapping("koc/monthly/search")
    public Response<KocProjectSearchVO> kocMonthlySearch(@RequestBody KocProjectSearchDto kocProjectSearchDto) {
        return Response.success(docKocpmHeaderService.kocMonthlySearch(kocProjectSearchDto));
    }

    /**
     * kou项目选择
     *
     * @param kocProjectSearchDto
     * @return
     */
    @PostMapping("koc/project/search")
    public Response<KocProjectSearchVO> kocProjectSearch(@RequestBody KocProjectSearchDto kocProjectSearchDto) {
        return Response.success(docKocpmHeaderService.kocProjectSearch(kocProjectSearchDto));
    }


}
